home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Hacks / Hacks ’95 / WelcomeToMacDialogsSuck / Part 3 / WelcomeToMacintoshDialogsSuck.c < prev    next >
C/C++ Source or Header  |  1995-06-24  |  3KB  |  154 lines

  1. #include <resources.h>
  2. #include <quickdraw.h>
  3. #include <Events.h>
  4.  
  5. void main( void);
  6. void DoWelcomeToMacintosh( void);
  7. void WhereToDrawMyPicture( Rect *r, PicHandle p);
  8. void DrawMyPicture( PicHandle p);
  9. void OffSetPictRect( Rect *rect);
  10. void DrawMyEaterPicture( PicHandle p);
  11. void CalcPictOffset( 
  12.                 Point *offset, 
  13.                 Point screenSize, 
  14.                 Rect *pictRect);
  15. Point *GetScreenSizePointPtr( void) =
  16.     {    0x41ED, 0xFF8C    };
  17.  
  18. #define __APPLICATION__        0
  19.  
  20. #if __APPLICATION__
  21. Point    gScreenSize = {480, 640};
  22. #endif
  23.  
  24. void main( void)
  25. {
  26. #if __APPLICATION__
  27.     Debugger();
  28.     InitGraf( &qd.thePort);
  29.     InitWindows();
  30.     SetApplLimit( GetApplLimit() -50000);
  31. #endif
  32.  
  33.     DoWelcomeToMacintosh();
  34. }
  35.  
  36. void DoWelcomeToMacintosh( void)
  37. {
  38.     PicHandle        badPict, goodPict;
  39.     short            rsrcNum;
  40.     Rect            rect;
  41.     
  42. /*
  43.     rsrcNum = 1;
  44.     if( IsPressed1( 0x0F))
  45.         rsrcNum = 2;
  46.  */
  47.     
  48.     badPict = GetPicture( 5);
  49.     goodPict = GetPicture( 1);
  50.     if( badPict && goodPict)
  51.     {
  52.         WhereToDrawMyPicture( &rect, badPict);
  53.         OffsetRect( &rect, 0, -32);
  54.         DrawPicture( badPict, &rect);
  55.         FrameRect( &rect);
  56.         InsetRect( &rect, 2, 2);
  57.         PenSize( 2, 2);
  58.         FrameRect( &rect);
  59.         DrawMyEaterPicture( goodPict);
  60. //        ReleaseResource( (Handle) badPict);
  61. //        ReleaseResource( (Handle) goodPict);
  62.     }
  63. }
  64.  
  65. void DrawMyEaterPicture( PicHandle p)
  66. {
  67.     Rect                rect;
  68.     short                Vdelta;
  69.     Rect                eraseRect;
  70.     short                i;
  71.     unsigned char        grayPat[8];
  72.     
  73.     for( i = 0; i < 8; i+=2)
  74.     {
  75.         grayPat[i+0] = 0xAA;
  76.         grayPat[i+1] = 0x55;
  77.     }
  78.     
  79.     WhereToDrawMyPicture( &rect, p);
  80.     Vdelta = rect.bottom;
  81.  
  82. #define    SLOW            3
  83. #define FAST            8    
  84. #define VFAST            16
  85.     
  86.     eraseRect = rect;
  87.     eraseRect.bottom = eraseRect.top +SLOW;
  88.  
  89.     rect.top -= Vdelta;
  90.     rect.bottom -= Vdelta;
  91.     eraseRect.top -= Vdelta;
  92.     eraseRect.bottom -= Vdelta;
  93.     
  94.     for( i = 0; i < (Vdelta >>2); i+= SLOW)
  95.     {
  96.         rect.top += SLOW;
  97.         rect.bottom += SLOW;
  98.         eraseRect.top += SLOW;
  99.         eraseRect.bottom += SLOW;
  100.         DrawPicture( p, &rect);
  101.         FillRect( &eraseRect, (PatPtr) grayPat);
  102.     }
  103.  
  104.     eraseRect.bottom = eraseRect.top +FAST;
  105.     for( ; i < (Vdelta >>1); i += FAST)
  106.     {
  107.         rect.top += FAST;
  108.         rect.bottom += FAST;
  109.         eraseRect.top += FAST;
  110.         eraseRect.bottom += FAST;
  111.         DrawPicture( p, &rect);
  112.         FillRect( &eraseRect, (PatPtr) grayPat);
  113.     }
  114.  
  115.     eraseRect.bottom = eraseRect.top +VFAST;
  116.     for( ; i < Vdelta; i += VFAST)
  117.     {
  118.         rect.top += VFAST;
  119.         rect.bottom += VFAST;
  120.         eraseRect.top += VFAST;
  121.         eraseRect.bottom += VFAST;
  122.         DrawPicture( p, &rect);
  123.         FillRect( &eraseRect, (PatPtr) grayPat);
  124.     }
  125.     DrawPicture( p, &rect);
  126. }
  127.  
  128. void WhereToDrawMyPicture( Rect *rect, PicHandle p)
  129. {
  130.     short            width, height;
  131.     Point            *screenSize;
  132.     
  133.     screenSize = GetScreenSizePointPtr();
  134.     *rect = (**p).picFrame;
  135.     width = rect->right - rect->left;
  136.     height = rect->bottom - rect->top;
  137.  
  138.     rect->left = 0;
  139.     rect->top = 0;
  140.     rect->right = width;
  141.     rect->bottom = height;
  142.  
  143.     if( (width <= 32) ||
  144.         (height <= 32))
  145.     {
  146.         width *= 5;
  147.         height *= 5;
  148.         rect->right += width;
  149.         rect->bottom += height;
  150.     }
  151.     OffsetRect( rect, (screenSize->h - width) >>1,
  152.                       (screenSize->v - height) >>1);
  153. }
  154.